const db = wx.cloud.database()
Page({
  data: {
    orderState: ["待确认", "已确认", "已完成"],
    orderDesc:["订单已提交，正在等待现场确认","确认通过，请等待飞手作业","订单已完成，欢迎下次使用呲呲打药"],
    flag:0,
    orderDetails:[],
  },
  onLoad:function(e){
    db.collection('Order').where({
     _id: e._id
    }).get({
      success: res => {
       // console.log(res.data)
        this.setData({
          orderDetails: res.data,
          flag:res.data[0].orderState,
          b_id: res.data[0]._id
        })
      }
   })
  },
  //取消订单
  buttonOnClick_delOrderfunction(e) {
   // console.log(this.data.b_id)
    db.collection('Order').doc(this.data.b_id).remove({
      success: res=>{
        wx.navigateBack({
          delta:1
        })
        wx.showToast({
          title: '您已取消订单',
        })
      },
      fail: console.error
    })
  },
})